<?php
/***
* +----------------------------------------------------------------------+
* | DATE: 2007-7-11                                                      |
* +----------------------------------------------------------------------+
* | Author: YuYii <fin1983@Hotmail.com>                                  |
* +----------------------------------------------------------------------+
*/

$file = "account_db.sql";
$dbLocation = "account.db";
if (file_exists($dbLocation) && filesize($dbLocation)!=0) die("Database already exists!<br/>Auto redirect to homepage in 5 seconds.<script>setTimeout(\"document.location.href='./'\", 5000);</script>");
if (file_exists($file)) {
	$filecontents = file_get_contents($file);
	$sqlcontents = explode("/*****start******/",$filecontents);
	$sql = explode(";",$sqlcontents[1]);
	foreach($sql as $k=>&$v){
		$temp = trim($v);
		if (empty($temp))
			unset($sql[$k]);
		else 
			$v = $temp.";";
	}
	require_once("../class/mydb_sqlite.php");
	$db = new DB;
	if(!$db->_connect($dbLocation))
		die('DATABASE CREATE ERROR');
	echo date("Y-m-d h:i:s");
	if ($db->executeBatch($sql)) echo "Database init successfully<br/>Auto redirect to homepage in 5 seconds.<script>setTimeout(\"document.location.href='./'\", 5000);</script>";
	else echo "Database init failed";
}
else {
	echo "Script file not found";
}


?>